package com.android.DBTools;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

//数据库的增删改查
public class ADUS {

	// 数据库的查询操作 返回resultset
	public static ResultSet selectData(String sql) throws SQLException, ClassNotFoundException {
		Connection con = DBConnection.getCon();
		PreparedStatement pst = con.prepareStatement(sql);
		ResultSet resultSet = pst.executeQuery(sql);
		return resultSet;
	}

	// 数据库的插入功能
	public static void insertData(String sql) throws ClassNotFoundException, SQLException {
		Connection con = DBConnection.getCon();
		PreparedStatement pst = con.prepareStatement(sql);
		pst.executeUpdate(sql);
	}

	// 数据库的修改功能
	public static void updateData(String sql) throws SQLException, ClassNotFoundException {
		Connection con = DBConnection.getCon();
		PreparedStatement pst = con.prepareStatement(sql);
		pst.executeUpdate(sql);
	}

	// 数据库的删除功能
	public static void deleteData(String sql) throws SQLException, ClassNotFoundException {
		Connection con = DBConnection.getCon();
		PreparedStatement pst = con.prepareStatement(sql);
		pst.executeUpdate(sql);
	}
}
